home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / emulate / zxupload.arc / Z80.S < prev    next >
Text File  |  1992-05-31  |  2KB  |  63 lines

  1. ;midixfer (Spectrum version)
  2. ;by Stephen K Mulrine
  3. ;load any normal Spectrum program/code (less than 41456 bytes)
  4. ;and shove the whole lot through the RAM Music Machine's MIDI OUT
  5. ;fun for all the family!
  6.     org 23296    ;assemble into printer buffer
  7.     xor a
  8.     scf
  9.     ld ix,24064
  10.     ld de,17
  11.     call 1366    ;load a 17-byte header at 24064
  12.     ld hl,(24075)    ;get length of file
  13.     ex de,hl
  14.     ld ix,24081
  15.     ld a,255
  16.     scf
  17.     call 1366    ;load rest of file after header in memory
  18.     ld a,1
  19.     out (95),a    ;replace interrupts with ACIA IRQ signal
  20.     ld bc,127
  21.     ld a,21
  22.     out (c),a    ;keep Spectrum's hands off ACIA
  23.     ld de,17
  24.     ld hl,(24075)
  25.     add hl,de    ;total number of bytes to transfer
  26.     ex de,hl
  27.     ld bc,383
  28.     ld a,e
  29.     out (c),a    ;send LSB of length down cable
  30.     ld bc,639
  31. loop1    in a,(c)    ;read status
  32.     bit 1,a
  33.     jr z,loop1    ;wait until sent
  34.     ld bc,383
  35.     ld a,d
  36.     out (c),a    ;send MSB of length down cable
  37.     ld bc,639
  38. loop2    in a,(c)    ;read status
  39.     bit 1,a
  40.     jr z,loop2    ;wait until sent
  41.     inc de        ;can't remember why I did this
  42.     ld hl,24064
  43. loop3    ld bc,383    ;dig those labels
  44.     ld a,(hl)    ;get byte to send
  45.     out (c),a    ;send it
  46.     and 7
  47.     out (254),a    ;tamper with border for laffs
  48.     ld bc,639
  49. loop4    in a,(c)    ;read status (again)
  50.     bit 1,a
  51.     jr z,loop4    ;wait until sent (again)
  52.     inc hl
  53.     dec de        ;I assembled this by hand, you know
  54.     ld a,d
  55.     or e        ;all bytes sent?
  56.     jr nz,loop3    ;this is how the pros do it, honest
  57.     ld bc,127
  58.     ld a,131
  59.     out (c),a    ;give ACIA back to Spectrum
  60.     xor a
  61.     out (95),a    ;restore interrupts
  62.     ret        ;auf wiedersehen
  63.